home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / amigaoscd / amigapluscd / AP-Website / forum / wbboard / thread.php < prev    next >
Text File  |  2002-03-15  |  9KB  |  195 lines

  1. <? 
  2. require("_functions.php");
  3. require("_header.php");
  4. require("_board_jump.php");
  5.  
  6. if($goto) {
  7.     $time = $db_zugriff->query_first("SELECT timelastreply as time FROM bb".$n."_threads WHERE threadid='$threadid'");
  8.     if($goto == "nextoldest") $nextthread = $db_zugriff->query_first("SELECT threadid FROM bb".$n."_threads WHERE timelastreply < '".$time[time]."' AND boardparentid='$boardid' ORDER by timelastreply DESC LIMIT 1");
  9.     if($goto == "nextnewest") $nextthread = $db_zugriff->query_first("SELECT threadid FROM bb".$n."_threads WHERE timelastreply > '".$time[time]."' AND boardparentid='$boardid' ORDER by timelastreply ASC LIMIT 1");
  10.     $threadid = $nextthread[threadid];
  11. }
  12. $thread_info = $db_zugriff->query_first("SELECT * FROM bb".$n."_threads WHERE threadid = '$threadid'");
  13. if($boardid != $thread_info[boardparentid]) { 
  14.     eval("dooutput(\"".gettemplate("hack_error")."\");");
  15.     exit;
  16. }
  17. $threadname = prepare_topic($thread_info[threadname]);
  18.  
  19. $db_zugriff->query("UPDATE bb".$n."_threads SET views=views+1 WHERE threadid='$threadid'");
  20. $sthreadname = "sthread_".$threadid;
  21. $$sthreadname = $thread_info[timelastreply];
  22. session_register("$sthreadname");
  23.  
  24. $anzahl = $thread_info[replies]+1;
  25. if(!$page) $page=1;
  26.  
  27. $result = $db_zugriff->query("SELECT * FROM bb".$n."_ranks ORDER BY posts DESC");
  28. while($row=$db_zugriff->fetch_array($result)) $rankcache[$row[groupid]][]=$row;
  29.  
  30. function getRank($posts,$groupid) {
  31.  global $rankcache;
  32.  for($i=0;$i<count($rankcache[$groupid]);$i++) {
  33.   if($rankcache[$groupid][$i][posts]==0) {
  34.    return $rankcache[$groupid][$i];
  35.    break;
  36.   }
  37.   elseif($posts/$rankcache[$groupid][$i][posts]>=1) {
  38.    return $rankcache[$groupid][$i];
  39.    break;
  40.   } 
  41.  }
  42. }
  43.  
  44. $getpostids=$db_zugriff->query("SELECT postid FROM bb".$n."_posts WHERE bb".$n."_posts.threadparentid='$threadid' ORDER by bb".$n."_posts.posttime ".ifelse($postorder,"DESC","ASC")." LIMIT ".($eproseite*($page-1)).",".($eproseite));
  45. while($row=$db_zugriff->fetch_array($getpostids)) $postids.=",".$row[postid];
  46.  
  47. $post_result = $db_zugriff->query("
  48.     SELECT bb".$n."_posts.*, bb".$n."_avatars.extension as avatarextension, bb".$n."_user_table.*, bb".$n."_useronline.zeit FROM bb".$n."_posts
  49.     LEFT JOIN bb".$n."_user_table ON (bb".$n."_user_table.userid = bb".$n."_posts.userid)
  50.     LEFT JOIN bb".$n."_avatars ON (bb".$n."_avatars.id = bb".$n."_user_table.avatarid)
  51.     LEFT JOIN bb".$n."_useronline ON (bb".$n."_useronline.userid = bb".$n."_posts.userid AND bb".$n."_useronline.userid>0)
  52.     WHERE bb".$n."_posts.postid IN (0$postids) ORDER by bb".$n."_posts.posttime ".ifelse($postorder,"DESC","ASC"));
  53. $pages=ceil($anzahl/$eproseite); 
  54. unset($j);
  55.  
  56. while($posts = $db_zugriff->fetch_array($post_result)){
  57.     
  58.     unset($posttopic);
  59.     unset($lastedit);
  60.     unset($user_pic);
  61.     unset($signature);
  62.     unset($email);
  63.     unset($userhp);
  64.     unset($quote_and_edit);
  65.     unset($location);
  66.     unset($usericq);
  67.     unset($useraim);
  68.     unset($useryim);
  69.     unset($status);
  70.     unset($stars);
  71.     unset($user_on_off);
  72.     unset($search);
  73.     unset($profile);
  74.     unset($homie);
  75.     unset($pn);
  76.     unset($regdate);
  77.         
  78.     if($posts[userid]) {
  79.         if($pms && $userdata[canusepms]) eval ("\$pn = \"".gettemplate("thread_pm")."\";");     
  80.         $regdate = formatdate($posts[regdate],$regdateformat);
  81.         $location = htmlspecialchars(editDBdata($posts[location]));
  82.         
  83.         $rank = getRank($posts[userposts],$posts[groupid]);
  84.         if($rank) {
  85.          for($i = 0; $i<$rank[mal]; $i++) $stars .= "<img src=\"$rank[grafik]\" border=\"0\">";
  86.              $stars = "<a href=\"javascript:rank($rank[id])\" title=\"Informationen zum Rang $rank[rank]\">".$stars."</a>";
  87.     
  88.          if($posts[statusextra]) $status = editDBdata($posts[statusextra]);
  89.          else $status = $rank[rank]; 
  90.         }
  91.         
  92.         if($posts[avatarid] && !$hide_userpic && $avatars) $user_pic = "<br><img src=\"images/avatars/avatar-".$posts[avatarid].".".$posts[avatarextension]."\" border=0>";
  93.         if($posts[signatur] && $posts[signature] && !$hide_signature) {
  94.             $signatur = editSignatur($posts[signatur],$posts[disable_smilies]);
  95.             eval ("\$signature = \"".gettemplate("thread_signature")."\";");
  96.         }
  97.         if($posts[zeit]) eval ("\$user_on_off = \"".gettemplate("thread_useron")."\";");
  98.         else eval ("\$user_on_off = \"".gettemplate("thread_useroff")."\";");
  99.         if($posts[users_may_email]==1) eval ("\$email = \"".gettemplate("thread_email")."\";");
  100.         if($posts[userhp]) eval ("\$userhp = \"".gettemplate("thread_userhp")."\";");
  101.         if($posts[usericq]) {
  102.             $usericq = editDBdata($posts[usericq]);
  103.             eval ("\$usericq = \"".gettemplate("thread_usericq")."\";");
  104.         }
  105.         if($posts[aim]) {
  106.             $aim = editDBdata($posts[aim]);
  107.             eval ("\$useraim = \"".gettemplate("thread_useraim")."\";");
  108.         }
  109.         if($posts[yim]) {
  110.             $yim = editDBdata($posts[yim]);
  111.             eval ("\$useryim = \"".gettemplate("thread_useryim")."\";");
  112.         }
  113.         eval ("\$search = \"".gettemplate("thread_search")."\";");
  114.         eval ("\$profile = \"".gettemplate("thread_profile")."\";");
  115.         eval ("\$homie = \"".gettemplate("thread_homie")."\";");
  116.         $authorname = $posts[username];
  117.     }
  118.     else eval ("\$authorname = \"".gettemplate("lg_anonymous")."\";");
  119.         
  120.     $a_name = (($page-1)*$eproseite)+$j+1;
  121.     $backcolor = rowcolor($j);
  122.         
  123.     if($posts[posticon]) $posticon = "<img src=\"$posts[posticon]\">";
  124.     else $posticon = " ";
  125.     
  126.     $posttopic = prepare_topic($posts[posttopic]);
  127.     $post = editPost($posts[message],$posts[disable_smilies]);
  128.     
  129.     if($old_time <= $posts[posttime]) $postsign = "<IMG SRC=\"images/posticonnew.gif\">";
  130.     else $postsign = "<IMG SRC=\"images/posticon.gif\">";
  131.     $posttime = formatdate($posts[posttime],$longdateformat,1);
  132.         
  133.     if($posts[edittime]) {
  134.         if($posts[editorid]) $editorname = getUsername($posts[editorid]);
  135.         else eval ("\$editorname = \"".gettemplate("lg_anonymous")."\";");
  136.         $edittime = formatdate($posts[edittime],$longdateformat);
  137.         eval ("\$lastedit = \"".gettemplate("thread_lastedit")."\";");
  138.     }
  139.     if($thread_info[flags]!=1) eval ("\$quote_and_edit = \"".gettemplate("thread_quote_edit")."\";");
  140.         
  141.     eval ("\$thread_postbit .= \"".gettemplate("thread_postbit")."\";");
  142.     $j++;
  143. }
  144. $db_zugriff->free_result($post_result);
  145.                         
  146. $navi_chain = makenavichain("thread",$boardid,$threadid);
  147. $oldest = $db_zugriff->query_first("SELECT threadid FROM bb".$n."_threads WHERE boardparentid='$boardid' ORDER BY timelastreply ASC LIMIT 1");
  148. if($threadid != $oldest[threadid]) eval ("\$next_thread .= \"".gettemplate("thread_next_oldest")."\";");
  149. $newest = $db_zugriff->query_first("SELECT threadid FROM bb".$n."_threads WHERE boardparentid='$boardid' ORDER BY timelastreply DESC LIMIT 1");
  150. if($threadid != $newest[threadid]) eval ("\$next_thread .= \"".gettemplate("thread_next_newest")."\";");
  151.  
  152. eval ("\$newthread_reply  .= \"".gettemplate("thread_newthread")."\";");
  153. if(!getThreadflag($threadid)) eval ("\$newthread_reply  .= \"".gettemplate("thread_reply")."\";");
  154. else eval ("\$newthread_reply  .= \"".gettemplate("thread_closed")."\";");
  155.  
  156. if($pages>1) $page_link = makepagelink("thread.php?threadid=$threadid&boardid=$boardid$session", $page, $pages);
  157. if($thread_info[pquestion]) {
  158.     
  159.     $poll_check = $db_zugriff->query_first("SELECT COUNT(*) FROM bb".$n."_vote WHERE threadid='$threadid' AND userid = '$user_id'");
  160.     $ptitle = prepare_topic($thread_info[pquestion]);
  161.     if($poll_check[0] || $presult || ($thread_info[ptimeout] && time() >= ($thread_info[starttime]+$thread_info[ptimeout]*(24*3600)))) {
  162.         $votes_total = $db_zugriff->query_first("SELECT SUM(votes) FROM bb".$n."_poll WHERE threadid='$threadid'");
  163.         $total = $votes_total[0];
  164.         $poll_result = $db_zugriff->query("SELECT * FROM bb".$n."_poll WHERE threadid='$threadid'");
  165.         while($row = $db_zugriff->fetch_array($poll_result)) {
  166.             $field = prepare_topic($row[field]);
  167.             $votes = $row[votes];
  168.             
  169.             if($total) {
  170.                 $percent_float = $votes*100/$total;
  171.                 $percent = number_format($percent_float, 2);
  172.                 $percent_int = floor($percent_float)*3;    
  173.             }
  174.             else $percent = $percent_int = 0; 
  175.             
  176.             eval ("\$thread_poll_resultbit .= \"".gettemplate("thread_poll_resultbit")."\";");
  177.         }
  178.         if(check_boardobject($boardid,$user_id,"mod") || $userdata[issupermod]) eval ("\$mod_poll_edit = \"".gettemplate("thread_polledit")."\";");
  179.         eval ("\$poll = \"".gettemplate("thread_poll_result")."\";");
  180.     }
  181.     else {
  182.         $poll_result = $db_zugriff->query("SELECT * FROM bb".$n."_poll WHERE threadid='$threadid'");
  183.         while($row = $db_zugriff->fetch_array($poll_result)) {
  184.             $field = prepare_topic($row[field]);
  185.             eval ("\$thread_pollbit .= \"".gettemplate("thread_pollbit")."\";");
  186.         }
  187.         if(check_boardobject($boardid,$user_id,"mod") || $userdata[issupermod]) eval ("\$mod_poll_edit = \"".gettemplate("thread_polledit")."\";");
  188.         eval ("\$poll = \"".gettemplate("thread_poll")."\";");
  189.     }
  190. if(check_boardobject($boardid,$user_id,"mod") || $userdata[issupermod] || ($thread_info[authorid] && $thread_info[authorid]==$user_id && ($userdata[cancloseowntopic] || $userdata[candelowntopic]))) eval ("\$quick_mod = \"".gettemplate("thread_quick_mod")."\";");
  191. eval("dooutput(\"".gettemplate("thread")."\");");
  192. ?>
  193.             
  194.